package com.xiubai.appforpda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xiubai.appforpda.R;
import com.xiubai.appforpda.entity.TestBean;
import com.xiubai.appforpda.entity.TestCheckAssetsBean;

import java.util.List;

/**
 * @author: r3562939
 * @version: V1.0
 * @project: AppForPda
 * @description: description
 * @date: 2018/11/13
 * @time: 16:30
 */
public class CheckAssetsAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private List<TestCheckAssetsBean> mDatas;

    public CheckAssetsAdapter(Context context, List<TestCheckAssetsBean> datas) {
        mInflater = LayoutInflater.from(context);
        mDatas = datas;
    }

    //返回数据集的长度
    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.test_item, parent, false); //加载布局
            holder = new ViewHolder();

            holder.item_code = (TextView) convertView.findViewById(R.id.item_code);
            holder.item_name = (TextView) convertView.findViewById(R.id.item_name);
            holder.item_order = (TextView) convertView.findViewById(R.id.item_order);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        TestCheckAssetsBean bean = mDatas.get(position);
        holder.item_code.setText(bean.checkCode);
        holder.item_name.setText(bean.checkName);
//        holder.item_order.setText(bean.checkDepartment);
        holder.item_order.setText(bean.deptname);

        return convertView;
    }

    private class ViewHolder {
        TextView item_code;
        TextView item_name;
        TextView item_order;
    }
}